package com.atguigu.lease.web.admin.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.atguigu.lease.model.entity.RoomFacility;
import com.atguigu.lease.web.admin.service.RoomFacilityService;
import com.atguigu.lease.web.admin.mapper.RoomFacilityMapper;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

/**
* @author liubo
* @description 针对表【room_facility(房间&配套关联表)】的数据库操作Service实现
* @createDate 2023-07-24 15:48:00
*/
@Service
public class RoomFacilityServiceImpl extends ServiceImpl<RoomFacilityMapper, RoomFacility>
    implements RoomFacilityService{

    @Override
    public void insertByItemIdAndIds(Long itemId, List<Long> ids) {
        if (!CollectionUtils.isEmpty(ids)) {
            List<RoomFacility> roomFacilities = new ArrayList<>();
            for (Long id : ids) {
                RoomFacility build = RoomFacility.builder().roomId(itemId).facilityId(id).build();
                roomFacilities.add(build);
            }
            super.saveBatch(roomFacilities);
        }
    }
}




